package com.gxa.eshop.admin.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.net.URI;
import java.net.URISyntaxException;

public class HttpClientUtil {

    private static RestTemplate restTemplate = new RestTemplate();

    public static Object postWithParam(String uriString,  MultiValueMap<String, Object> paramMap,Class clazz) throws Exception {
        URI uri = new URI(uriString);
        Object o = restTemplate.postForObject(uri, paramMap, clazz);
       //System.out.println(result);
        return o;
    }

    public  static Object postWithoutParam(String uriString,Class clazz) throws Exception {
        // 使用Spring自己的RestTemplate
       return postWithParam(uriString,null,clazz);
    }


}
